package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.ContactUserEntity;
import com.xbongbong.saas.domain.entity.ProductionOrderUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/2/21 14:05
 * @since v1.0
 */
public interface ProductionOrderUserModel extends IModel<ProductionOrderUserEntity> {
    /**
     * 生产单协同团队数据插入
     *
     * @param entity BOM单协同团队实体
     * @throws XbbException 异常
     * @return Integer
     * @author long.rao
     * @date 2019-02-01 15:24
     */
    @Override
    Integer insert(ProductionOrderUserEntity entity) throws XbbException;
    /**
     * 生产单协同团队数据更新
     *
     * @param entity BOM单协同团队实体
     * @author long.rao
     * @date 2019-02-01 15:24
     * @throws XbbException 异常
     * @return Integer
     */

    @Override
    Integer update(ProductionOrderUserEntity entity) throws XbbException;
    /**
     * 生产单协同团队数据查询多个
     *
     * @param param 参数
     * @author long.rao
     * @date 2019-02-01 15:24
     * @return List<ProductionOrderUserEntity>
     */
    @Override
    List<ProductionOrderUserEntity> findEntitys(Map<String, Object> param);
    /**
     * 生产单协同团队数据查询条数
     * @param param 参数
     * @author long.rao
     * @date 2019-02-01 15:24
     * @return Integer
     */
    @Override
    Integer getEntitysCount(Map<String, Object> param);
    /**
     * 生产单协同团队数据单条查询
     * @param key 主键ID
     * @param corpid 公司ID
     * @author long.rao
     * @date 2019-02-01 15:24
     * @return Integer
     */
    ProductionOrderUserEntity getByKey(Long key, String corpid);
    /**
     * 保存实体
     *
     * @param bomUserEntity 生产单协同人团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author long.rao
     * @date 2019-02-17 16:47
     */
    Integer save(ProductionOrderUserEntity bomUserEntity) throws XbbException;
    /**
     * 批量删除
     * @param list 生产单id列表
     * @param corpid 公司id
     * @return
     */
    Integer deleteByProOrderIdIn(List<Long> list, String corpid) throws XbbException;

    /**
     * 查询协同团队基础列表
     *
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    /**
     * 获取协同团队的业务数据
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);

    /**
     * 删除
     *
     * @param productionOrderUserEntity 删除的对象
     * @author GuoJun.HU
     * @since V1.0
     * @throws XbbException XbbException
     * @date 2019/4/22 10:10
     */
    void delete(ProductionOrderUserEntity productionOrderUserEntity) throws XbbException;

    /**
     * 通过生产单的id获取团队
     *
     * @param corpid            公司id
     * @param productionOrderId 生产单的id
     * @return List
     * @author GuoJun.HU
     * @date 2019/4/19 15:39
     * @since V1.0
     */
    List<ProductionOrderUserEntity> getProductionOrderUserListByProductionOrderId(String corpid, Long productionOrderId);

    void insertBatch(List<ProductionOrderUserEntity> productionOrderUserEntityList, boolean isImport) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 批量剔除团队
     * @param corpid
     * @param removeIdList 客户团队表idList
     */
    Map<Long, String> batchDeleteById(String corpid, List<Long> removeIdList) throws XbbException;

    void deleteBatchUser(List<ProductionOrderUserEntity> productionOrderUserEntityList, String corpid, Integer del) throws XbbException;

    Integer deleteBatch(List<Long> list, String corpid, Integer del) throws XbbException;

    /**
     * 批量编辑
     * @param list
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer updateBatch(List<ProductionOrderUserEntity> list, String corpid) throws XbbException;





    /**
     * 编辑团队成员标签
     *
     * @param productionOrderUserEntity
     */
    void editLabel(ProductionOrderUserEntity productionOrderUserEntity) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param productionOrderUserEntity
     */
    void updateEditFormPer(ProductionOrderUserEntity productionOrderUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
}
